﻿using System.Text.Json;
using CapHttp.Core;
using CapHttp.Demo.Shared.Events;
using DotNetCore.CAP;

namespace CapHttp.Consumer.Api.Subscribers;

public class Test2Subscriber : IDistributedEventSubscriber
{
    private readonly ILogger<Test2Subscriber> _logger;

    public Test2Subscriber(ILogger<Test2Subscriber> logger)
    {
        _logger = logger;
    }

    [DistributedEventSubscribe]
    public void Event2Handler(Event2 @event)
    {
        _logger.LogInformation("Received event2: {data}", JsonSerializer.Serialize(@event));
    }
}